package com.cssw.fyzb.busi.api.task;

import com.cssw.fyzb.core.model.vo.task.UnsettledValueVo;
import com.cssw.fyzb.busi.service.task.TaskService;
import com.ydn.appserver.Action;
import com.ydn.appserver.Request;
import com.ydn.appserver.Response;
import com.ydn.appserver.annotations.Function;
import com.ydn.appserver.annotations.Parameter;
import com.ydn.appserver.annotations.Type;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author
 */
@Function(description = "未结算的平安果", parameters = {
        @Parameter(name = "userId", type = Type.String, description = "用户标识", required = true)
})
@Component
public class UnsettledValue implements Action {

    private final static Logger logger = LoggerFactory.getLogger(UnsettledValue.class);

    @Autowired
    private TaskService taskService;

    @Override
    public Response execute(Request request) throws Exception {
        Long userId = request.getLong("userId");
        try {
            String s = taskService.unsettledValue(userId);
            return Response.success().put("data", new UnsettledValueVo(s));
        } catch (Exception e) {
            logger.info("", e);
            return Response.fail("操作异常");
        }
    }
}
